home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb13.arc
/
DIR2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1980-01-01
|
3KB
|
125 lines
program Dir2;
{This program displays the default directory plus the free space
on both disks. It works only on MS-DOS (or PC-DOS) version 2. It
assumes a screen 80 columns wide and at least 24 lines deep. }
Type
regpack = record
case integer of
1: (ax,bx,cx,dx,bp,si,di,ds,es,flags: integer);
2: (al,ah,bl,bh,c,ch,dl,dh : byte)
end;
dtaarray = array[0..42] of byte;
dtacharray = array[0..42] of char;
const
getdta = $1a;
get1stdir = $4e;
getnextdir = $4f;
getfreespace = $36;
var
filestr: string[14];
dta: dtaarray;
cdta: dtacharray absolute dta;
tsize: byte;
x,y: Integer;
procedure DTAcall;
var
regs: regpack;
begin
with regs do begin
ah := getdta;
ds := seg(dta);
dx := ofs(dta);
MsDos(regs)
end
end; {DTAcall}
procedure Firstcall(var errflag: byte);
var
regs: regpack;
begin
with regs do begin
ah := get1stdir;
cx := 0;
ds := seg(filestr);
dx := ofs(filestr[1]);
MsDos(regs);
if (flags and 1) = 1 then errflag:= lo(ax)
else errflag:= 0
end
end; {firstcall}
procedure Nextcall(var errflag: byte);
var
regs: regpack;
begin
regs.ah := getnextdir;
MsDos(regs);
if (regs.flags and 1) = 1 then errflag:= regs.al
else errflag:= 0
end; {nextcall}
Function Freespace(drive: char):real;
var
regs: regpack;
fr: real;
begin
with regs do begin
dx := ord(drive) - 64;
ah := getfreespace;
MsDos(regs); { call function }
fr := bx;
if ax > 0 then Freespace := fr * ax * cx
else freespace:= 0
end
end; {freespace}
Procedure loaddir;
var
i, j: integer;
err: byte;
begin
clrscr;
gotoxy(35,2);
write('DIRECTORY');
filestr:= '*.*';
fillchar(dta, 42, 0);
DTAcall;
Firstcall(err);
j:= 0;
repeat
gotoxy(((j mod 3)*28)+1, (j div 3) + 4);
i:= 30;
while dta[i] <> 0 do begin
write(cdta[i]);
i:= i + 1
end;
for i:= i to 42 do write(' ');
write(dta[26] + 256. * dta[27] + 65536. * dta[28]:5:0, ' bytes');
j:= j + 1;
Nextcall(err)
until err <> 0;
gotoxy(1,23);
write('Drive A: ', freespace('A'):6:0, ' bytes free.');
gotoxy(50,23);
writeln('Drive B: ', freespace('B'):6:0, ' bytes free.');
end; {loaddir}
begin
loaddir
end.